package com.powernode.common.model;

import lombok.*;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class R<T> {
    private Integer code;

    private String message;

    private T data;

    public static <T> R<T> OK(T data) {
        return R.<T>builder()
                .code(BusinessEnum.SUCCESS.getCode())
                .message(BusinessEnum.SUCCESS.getDesc())
                .data(data)
                .build();
    }

    public static <T> R<T> FAIL(BusinessEnum businessEnum) {
        return R.<T>builder()
                .code(businessEnum.getCode())
                .message(businessEnum.getDesc())
                .build();
    }
}
